﻿@{
    ViewBag.Title = "产品列表";
    Layout = "~/Views/Shared/_Main.cshtml";
}
<div id="column">
    <div class="alert alert-warning" role="alert">
        <strong>目前没有数据!</strong>
    </div>
</div>
<script id="tpl-row1" type="textml">
    <div class="col-md-12">
        <table class="table">
            <thead>
                <tr>
                    <th>标题</th>
                    <th>副标题</th>
                    <th>所属栏目</th>
                    <th>封面</th>
                    <th>视频</th>
                </tr>
            </thead>
            <tbody>
                {{each ApiParamObj[0] as value i}}
                <tr>
                    <td>{{ value.Title }}</td>
                    <td>{{ value.Subtitle }}</td>
                    <td>{{ value.ColumnName }}</td>
                    <td>
                        {{if value.CoverURL != ''}}
                        <img style="width:50px; height:50px;" src="{{value.CoverURL}}" />
                        {{else}}
                        无
                        {{/if}}
                    </td>
                    <td>
                        {{if value.VideoURL != ''}}
                        <a href="{{ value.VideoURL }}">预览</a>
                        {{else}}
                        无
                        {{/if}}
                    </td>
                    <td>
                        <a href="Edit?ID={{ value.ID }}" class="btn btn-info btn-sm active" role="button">编辑</a>
                        <a href="javascript:void(0)" class="btn btn-danger btn-sm active" role="button" onclick="Delete('{{ value.ID }}',this)">删除</a>
                    </td>
                </tr>
                {{/each}}
            </tbody>
        </table>
    </div>
    <div id="pager" class="tcdPageCode"></div>
</script>
<script type="text/javascript">

    //初始化列表
    var init = {
        pageSize: 10,
        search: '',
        initList: function (page) {
            //分页绑定 API Type=SQL PagedQuery
            CJ.BindListPage({
                containerId: "#column",
                pagerId: "#pager",
                tplId: 'tpl-row1',
                callBack: function (xhr) {
                    console.log(xhr);
                },
                data: { API: 'Corey_GetNewss', sorts: 'CreateTime', pagesize: init.pageSize, page: page }
            });
        }
    };

    init.initList(1);

    function Delete(id, $this) {

        if (confirm('是否删除该条信息？')) {
            $.ajax({
                url: '/api/CommonApi?API=Corey_DeleteNews',
                type: 'get',
                data: { ID: id },
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $($this).parent().parent().remove();
                    }
                }
            });
        }

    }
</script>